jQuery(document).ready(function(){
	jQuery('#btnDelete').click(function(){			
		if(confirm('Are you sure want to delete this tube ?')){				
			showAjaxEffect();
			jQuery.get('/admin/tube/process', { 
				action: 'delete', 
				id: jQuery('#btnDelete').attr('href'), 
					} ,
				function( data ) {
					hideAjaxEffect();
					scrollToTop();
					if(data==''){			
						jQuery('#messageDiv').fadeIn();
						jQuery('#messageDiv').addClass('msgsuccess').removeClass('hidden');
						jQuery('#messageDiv > p').html('Action success ! Tube has been deleted. Redirecting...');
						setTimeout(function() {							
							window.location.href = '/admin/tube/list';
						}, 2000);	
					}else{
						jQuery('#messageDiv').fadeIn();
						jQuery('#messageDiv').addClass('msgerror').removeClass('hidden');
						jQuery('#messageDiv > p').html(data);
						setTimeout(function() {
							jQuery('#messageDiv').fadeOut();
						}, 2000);	
					}									
	     		}
			);				
		}
		return false;
	}); 

	jQuery('#btnBanner').click(function(){			
		showAjaxEffect();
		jQuery.get('/admin/tube/process', { 
			action: 'set-slide', 
			id: jQuery('#btnBanner').attr('href'), 
				} ,
			function( data ) {
				hideAjaxEffect();
				scrollToTop();
				if(data==''){			
					jQuery('#messageDiv').fadeIn();
					jQuery('#messageDiv').addClass('msgsuccess').removeClass('hidden');
					jQuery('#messageDiv > p').html('Action success ! Tube has been added to slideshow');
					setTimeout(function() {
						jQuery('#messageDiv').fadeOut();
					}, 2000);	
				}else{
					jQuery('#messageDiv').fadeIn();
					jQuery('#messageDiv').addClass('msgerror').removeClass('hidden');
					jQuery('#messageDiv > p').html(data);
					setTimeout(function() {
						jQuery('#messageDiv').fadeOut();
					}, 2000);	
				}	
     		}
		);	
		return false;
	}); 
});